Vue.component('v-line', {
    props: {
        it:Object
    },
    data: function () { 
        return {
            focus:false
        }
    },
    mounted: function () {
        App.eventBus.$on('lineAllBlur', function () { 
            this.focus = false;
        }.bind(this));

        App.eventBus.$on("lineDeleteCheck",function(){
            if (this.focus) {
                App.eventBus.$emit("lineDelete",this.it)
            }
        }.bind(this));
        
        // window.onkeydown = ...
    },
    methods: {
        lineFocus: function () {
            App.eventBus.$emit('lineAllBlur');
            this.$nextTick(function () {
                this.focus = true;
            })
        }
    },
    template:'<path @click.stop="lineFocus" :d="\'M\'+it.sx+\' \'+it.sy+\' L \'+it.ex+\' \'+it.ey" fill="transparent" :stroke="focus?\'#ff0000\':\'#cccccc\'" stroke-width="4"/>'
})